translator.service({
  meta : {
    version : "0.0.1",
    shortName : "google",
    name : "Google Translate",
    icon : "chrome://translator/skin/services/google.png",
    homepage : "http://translate.google.com"
  },
  
  init : function () {
    translator.languages.alias("FILIPINO", "fil");
  },

  translate : {
    charLimit : 512,
    method : function (options) {
      Mozkit.http.send({
        url : "http://www.google.com/uds/Gtranslate",
        method : "GET",
        dataType : "json",
        requestBody : {
          q : options.text,
          langpair : options.srcLang + "%7C" + options.destLang,
          v : "1.0"
        },
        callBack : function (response) {
          if ("responseData" in response && "translatedText" in response.responseData) {
            options.success(response.responseData.translatedText);
          } else {
            options.fail(response);
          }
        },
        error : function (error) {
          options.fail(error);
        }
      });
    }
  },
  
  detect : {
    url : "http://www.google.com/uds/GlangDetect",
    method : "GET",
    dataType : "json",
    params : {q : "{{text}}", v : "1.0"},
    get : function (data) {
      return data.responseData && (data.responseData.confidence * 15) >= 1 ?
        translator.languages.find(data.responseData.language) : false;
    }
  },
  
  langFilter : {
    "PORTUGUESE" : "pt-PT",
    "CHINESE_SIMPLIFIED" : "zh-CN",
    "CHINESE_TRADITIONAL" : "zh-TW"
  },
  
  langSets : {
    ARABIC : ["BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    BULGARIAN : ["ARABIC", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    CHINESE : ["ARABIC", "BULGARIAN", "CROATIAN", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    CROATIAN : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    CZECH : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    DANISH : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    DUTCH : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    ENGLISH : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "DUTCH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    FINNISH : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    FRENCH : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    GERMAN : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    GREEK : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    HINDI : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    ITALIAN : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    JAPANESE : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    KOREAN : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    NORWEGIAN : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    POLISH : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    PORTUGUESE : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "ROMANIAN", "RUSSIAN", "SPANISH", "SWEDISH"],
    ROMANIAN : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "RUSSIAN", "SPANISH", "SWEDISH"],
    RUSSIAN : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "SPANISH", "SWEDISH"],
    SPANISH : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SWEDISH"],
    SWEDISH : ["ARABIC", "BULGARIAN", "CHINESE_SIMPLIFIED", "CHINESE_TRADITIONAL", "CROATIAN", "CZECH", "DANISH", "DUTCH", "ENGLISH", "FINNISH", "FRENCH", "GERMAN", "GREEK", "HINDI", "ITALIAN", "JAPANESE", "KOREAN", "NORWEGIAN", "POLISH", "PORTUGUESE", "ROMANIAN", "RUSSIAN", "SPANISH"]
  }
});
